import { http } from "@/utils/http";

type Result = {
  current_page: number;
  result?: any;
  per_page?: number;
  total?: number;
};
type ResultTable = {
  success: boolean;
  data?: {
    /** 列表数据 */
    list: Array<any>;
    /** 总条目数 */
    total?: number;
    /** 每页显示条目个数 */
    pageSize?: number;
    /** 当前页数 */
    currentPage?: number;
  };
};
type ResultCreate = {
  code: number;
  msg: string;
};
type ResultDelete = {
  code: number;
  msg: string;
};
type Show = {
  code: number;
  msg: string;
  result?: any;
};
/** 获取系统管理-用户管理列表 */
export const getUserList = (data?: object) => {
  return http.request<ResultTable>("post", "/user", { data });
};

/** 系统管理-用户管理-获取所有角色列表 */
export const getAllRoleList = () => {
  return http.request<Result>("get", "/list-all-role");
};

/** 系统管理-用户管理-根据userId，获取对应角色id列表（userId：用户id） */
export const getRoleIds = (data?: object) => {
  return http.request<Result>("post", "/list-role-ids", { data });
};

/** 获取系统管理-角色管理列表 */
export const getRoleList = (data?: object) => {
  return http.request<ResultTable>("post", "/role", { data });
};

/** 获取系统管理-菜单管理列表 */
export const getMenuList = (data?: object) => {
  return http.request<Result>("post", "/menu", { data });
};

/** 获取系统管理-部门管理列表 */
export const getDeptList = (data?: object) => {
  return http.request<Result>("post", "/dept", { data });
};

/** 获取系统监控-在线用户列表 */
export const getOnlineLogsList = (data?: object) => {
  return http.request<ResultTable>("post", "/online-logs", { data });
};

/** 获取系统监控-登录日志列表 */
export const getLoginLogsList = (data?: object) => {
  return http.request<ResultTable>("post", "/login-logs", { data });
};

/** 获取系统监控-操作日志列表 */
export const getOperationLogsList = (data?: object) => {
  return http.request<ResultTable>("post", "/operation-logs", { data });
};

/** 获取系统监控-系统日志列表 */
export const getSystemLogsList = (data?: object) => {
  return http.request<ResultTable>("post", "/system-logs", { data });
};

/** 获取系统监控-系统日志-根据 id 查日志详情 */
export const getSystemLogsDetail = (data?: object) => {
  return http.request<Result>("post", "/system-logs-detail", { data });
};

/** 获取角色管理-权限-菜单权限 */
export const getRoleMenu = (data?: object) => {
  return http.request<Result>("post", "/role-menu", { data });
};

/** 获取角色管理-权限-菜单权限-根据角色 id 查对应菜单 */
export const getRoleMenuIds = (data?: object) => {
  return http.request<Result>("post", "/role-menu-ids", { data });
};
/** 菜单列表 */
export const getRbacMenuListApi = (params?: object) => {
  return http.request<Result>("get", "/dashboard/rbacMenu/list", {
    params
  });
};
/** 菜单添加 */
export const createRbacMenuApi = (data?: object) => {
  return http.request<ResultCreate>("post", "/dashboard/rbacMenu/store", {
    data
  });
};
/** 菜单修改 */
export const updateRbacMenuApi = (data?: object) => {
  return http.request<ResultCreate>("put", "/dashboard/rbacMenu/update", {
    data
  });
};
/** 菜单删除 */
export const delRbacMenuApi = (params?: object) => {
  return http.request<ResultDelete>("delete", "/dashboard/rbacMenu/delete", {
    params
  });
};
/** 菜单详情 */
export const getRbacMenuShowApi = (params?: object) => {
  return http.request<Show>("get", "/dashboard/rbacMenu/show", {
    params
  });
};
/** 菜单选择 */
export const getRbacMenuListTreeApi = (params?: object) => {
  return http.request<Result>("get", "/dashboard/rbacMenu/select", {
    params
  });
};
/** 菜单已用图标 */
export const getRbacMenuIconIndexApi = (params?: object) => {
  return http.request<Result>("get", "/dashboard/rbacMenu/iconIndex", {
    params
  });
};
/** 菜单状态修改 */
export const updateRbacMenuStatusApi = (data?: object) => {
  return http.request<ResultCreate>("put", "/dashboard/rbacMenu/updateStatus", {
    data
  });
};
/** 用户状态修改 */
export const updateUserStatusApi = (data?: object) => {
  return http.request<ResultCreate>("put", "/dashboard/user/updateStatus", {
    data
  });
};